<%@page import="java.util.SortedMap"%>
<%@page import="com.nope.dodkr.DODContext"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Set"%>
<%@page import="com.nope.dodkr.DODItem"%>
<%@page import="com.nope.dodkr.DODXMLWorker"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%

String rootPath = pageContext.getServletContext().getRealPath("/dod");
//System.out.println(rootPath);
String[] targetAttributes = new String[]{"name", "text", "description", "subtype"};
String[] excludeTags = new String[]{"sound", "dieSprite", "row", "tile", "castSpellSprite", "blocker", "startPhoneme", "phoneme", "material", "encrustwith", "customblocker", "decor", "ichor"};
List<DODItem> list = DODXMLWorker.getDistinctStrings(rootPath, targetAttributes, excludeTags, 6000); 
List<DODContext> contextList = null;
int total = list.size();

%>
<!doctype html>
<html>
<title></title>
<head>
<style type="text/css">
*{margin: 0; padding: 0;font-size: 12px;font-family: 나눔고딕, dotum}
body{padding: 10px;}
ul{list-style: none;}
table{border-collapse: collapse;border: 1px solid #CCCCCC; width: 100%;margin-top: 10px;}
th, td{padding: 5px;border: 1px solid #CCCCCC;}
th{background-color: #EEEEEE; width: 100px;}
.translated th{background-color: green;}
</style>
<script type="text/javascript">
function checkForm(f){
	if(!f.to.value){
		f.to.focus();
		return false;
	}
	return true;
}
//window.onload = function(){
//	document.getElementById('<%= request.getParameter("backTo") %>').focus();
//};
</script>
</head>
<body>
<p>
	TRANSLATED : <%= DODXMLWorker.countTranslated(list) %> / TOTAL : <%= total %>
</p>
<%
	DODItem dodItem = null;
	for(int i = 0; i<total; i++){
		dodItem = list.get(i);
%>
<table <% if( DODXMLWorker.isTranslated(dodItem.getKeyText()) ){ out.print("class=\"translated\""); } %> >
	<tbody>
		<tr>
			<th>CONTEXT</th>
			<td>
				<ul>
					<%
					contextList = dodItem.getContextList();
					for(DODContext dodContext : contextList){
					%>
					<li>
						&lt;<%= dodContext.getTagName() %> <%= dodContext.getContext() %> /&gt;<span style="font-size: 8px;">(<%= dodContext.getFileName() %></span>
					</li>
					<%
					}
					%>
				</ul>
			</td>
		</tr>
		<tr>
			<th>
			FROM
			</th>
			<td>
				<%= dodItem.getKeyText() %>
			</td>
		</tr>
		<tr>
			<th>
			TO
			</th>
			<td>
				<form action="work.jsp" method="post" onsubmit="return checkForm(this);">
					<input type="hidden" name="from" value="<%= dodItem.getKeyText().replace("\"", "&quot;") %>" />
					<input type="hidden" name="backTo" value="item<%= i %>"  />
					<input type="text" id="item<%= i %>" name="to" value="" style="width: 100%;" />
					<%--
					<div style="text-align: right;">
						<input type="submit" value="OK" />
					</div>
					--%>
				</form>
			</td>
		</tr>
	</tbody>
</table>
<%
	}
%>
</body>
</html>